package hero

import (
	"idle/internal/game/attr"
	"idle/internal/game/equip"
	"idle/internal/game/equip/slot"
	"idle/internal/game/fight"
	"idle/internal/game/skill"
)

type Hero struct {
	fight.Fighter
	Name       string
	Lv         int
	Exp        int
	Hp         int
	Mana       int
	Job        HeroJob                    //职业
	attrMap    map[attr.Attribute]int     //属性
	EquipMap   map[slot.Slot]*equip.Equip //装备
	SkillList  []skill.Skill
	CreateTime int64 //创建时间
	Gold       int64 //金币数量
}

func NewHero() *Hero {
	return &Hero{
		attrMap:   make(map[attr.Attribute]int),
		EquipMap:  make(map[slot.Slot]*equip.Equip),
		SkillList: make([]skill.Skill, 0),
	}
}

func (h *Hero) GetEquip(slot slot.Slot) *equip.Equip {
	if eq, ok := h.EquipMap[slot]; ok {
		return eq
	}
	return nil
}

func (h Hero) SetEquip(slot slot.Slot, eq *equip.Equip) {
	h.EquipMap[slot] = eq
}

func (h *Hero) GetAttr(attr attr.Attribute) int {
	if val, ok := h.attrMap[attr]; ok {
		return val
	}
	h.attrMap[attr] = 0
	return 0
}

func (h *Hero) SetAttr(attr attr.Attribute, value int) {
	h.attrMap[attr] = value
}

func (h *Hero) GetCopyAttrMap() map[attr.Attribute]int {
	result := make(map[attr.Attribute]int)
	for k, v := range h.attrMap {
		result[k] = v
	}
	return result
}
